import { req_login } from "@/api/user";

export default {
    namespaced: true,
    state() {
        return {
            token: ''
        }
    },
    mutations: {
        setUserToken(state, payload) {
            state.token = payload
        },
        // 清空token
        logout(state) {
            state.token = ''
        }
    },
    actions: {
        async loginAction(context, payload) {
            const res = await req_login(payload)
            context.commit('setUserToken', res.data.token)
        }
    }
}